<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增分类属性名')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-supplyclasskey-add">
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">分类ID：</label>-->
<!--                <div class="col-sm-8">-->
                    <input id="treeId" name="supplyClassId" class="form-control" type="hidden" required>
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">分类ID：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="supplyClassName" onclick="selectSClassTree()" id="treeName" placeholder="请选择所属分类" class="form-control" type="text"  readonly="true" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">属性名称：</label>
                <div class="col-sm-8">
                    <input name="attrName" class="form-control" type="text">
                </div>
            </div>
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">创建时间：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="input-group date">-->
<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
<!--                        <input name="createAt" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "jiaqin/supplyclasskey"
        $("#form-supplyclasskey-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-supplyclasskey-add').serialize());
            }
        }

        $("input[name='createAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        /*属性值管理-新增-选择分类树*/
        function selectSClassTree() {
            var treeId = $("#treeId").val();
            var supplyClassId = $.common.isEmpty(treeId) ? "0" : $("#treeId").val();
            var url = ctx + "jiaqin/supplyclass/selectSupplyClassTree/"+supplyClassId;
            var options = {
                title: '选择分类',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }
    </script>
</body>
</html>
